package com.charonmc.utils;

import net.minecraft.server.v1_8_R3.*;
import org.bukkit.entity.Player;


/**
 * MessageUtils管理服务端与客户端信息传递方法
 * @author ChuYang
 */

public class MessageUtils {

    /**
     * 向玩家发送聊天栏信息
     * @param player 目标玩家
     * @param msg 所要发送的信息
     */
    public static void sendChatMessage(Player player, IChatBaseComponent msg) {
        NetworkUtils.sendPacket(player, new PacketPlayOutChat(msg));
    }

    /**
     * 向玩家发送标题信息
     * @param player 目标玩家
     * @param title 主标题信息
     * @param subTitle 副标题信息
     * @param s 尚不明确
     * @param d 尚不明确
     * @param e 尚不明确
     */
    public static void sendTitle(Player player, String title, String subTitle, int s, int d, int e) {
        NetworkUtils.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, new ChatComponentText(title), s, d, e));
        NetworkUtils.sendPacket(player, new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, new ChatComponentText(subTitle), s, d, e));
    }

    /**
     * 向玩家发送ActionBar(物品栏上方)信息
     * @param player 目标玩家
     * @param msg 所要发送的信息
     */
    public static void sendActionBar(Player player, IChatBaseComponent msg) {
        NetworkUtils.sendPacket(player, new PacketPlayOutChat(msg, (byte) 2));
    }

}
